package com.fp.m7.server.helpers;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.springframework.stereotype.Component;

import com.fp.m7.api.model.Account;
import com.fp.m7.shared.dto.UserDto;

/**
 * Factory for creating UserDtos.
 * 
 * @author 7
 */
@Component
public class UserDtoFactory {

    public UserDto build(Account account) {
        return new UserDto(account.getId(), account.getNickname(), account.getAvatarUrl());
    }

    public List<UserDto> build(Collection<Account> accounts) {
        List<UserDto> rtrn = new ArrayList<UserDto>(accounts.size());
        for (Account account : accounts) {
            if (account != null) {
                rtrn.add(build(account));
            }
        }
        return rtrn;
    }

}
